{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "645750af",
   "metadata": {},
   "source": [
    "# Web服务API简介\n",
    "* 高德Web服务API向开发者提供HTTP接口，开发者可通过这些接口使用各类型的地理数据服务，返回结果支持JSON和XML格式。Web服务API对所有用户开放。使用本组服务之前，需要申请应用Key。不同类型用户可获取不同的数据访问能力。\n",
    "##\n",
    "* 结构化地址:\n",
    "> 首先，地址肯定是一串字符，内含国家、省份、城市、区县、城镇、乡村、街道、门牌号码、屋邨、大厦等建筑物名称。按照由大区域名称到小区域名称组合在一起的字符。一个有效的地址应该是独一无二的。注意：针对大陆、港、澳地区的地理编码转换时可以将国家信息选择性的忽略，但省、市、城镇等级别的地址构成是不能忽略的。暂时不支持返回台湾省的详细地址信息。\n",
    "* 结构化地址<--->经纬度\n",
    "> 地理编码/逆地理编码 API 是通过 HTTP/HTTPS 协议访问远程服务的接口，提供结构化地址与经纬度之间的相互转化的能力"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "cfc4af34",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1. 调用requests模块（google chrome 浏览器）\n",
    "import requests\n",
    "# 2. 请求方法 ： GET\n",
    "# 3. URL地址 ： https://restapi.amap.com/v3/geocode/geo?parameters\n",
    "geo_url = \"https://restapi.amap.com/v3/geocode/geo?parameters\"\n",
    "# 4. 准备参数，用于交换数据 payload\n",
    "payload = {\n",
    "    \"key\":\"b0121f143057c2f0c3607e48fe21bac9\",\n",
    "    \"address\":\"广东省广州市从化区广州南方学院\"\n",
    "}\n",
    "# 5. 发起请求\n",
    "r = requests.get(url=geo_url, params=payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "318aca3c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "4f1d992f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'count': '1',\n",
       " 'geocodes': [{'formatted_address': '广东省广州市从化区温泉镇中心大学南方学院',\n",
       "   'country': '中国',\n",
       "   'province': '广东省',\n",
       "   'citycode': '020',\n",
       "   'city': '广州市',\n",
       "   'district': '从化区',\n",
       "   'township': [],\n",
       "   'neighborhood': {'name': [], 'type': []},\n",
       "   'building': {'name': [], 'type': []},\n",
       "   'adcode': '440117',\n",
       "   'street': [],\n",
       "   'number': [],\n",
       "   'location': '113.678280,23.628439',\n",
       "   'level': '兴趣点'}]}"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "0b616e47",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'113.678280,23.628439'"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院_location = r.json()['geocodes'][0]['location']\n",
    "广州南方学院_location"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ef2fbf97",
   "metadata": {},
   "source": [
    "# 逆地理编码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "ba635e26",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1.调用requests模块 (打开google chrome 浏览器)\n",
    "import requests\n",
    "# 2. URL：https://restapi.amap.com/v3/geocode/geo?parameters\n",
    "geo_url = \"https://restapi.amap.com/v3/geocode/geo?parameters\"\n",
    "# 3. 请求方法：GET\n",
    "# 4. 准备请求参数，用于交换数据payload\n",
    "payload = {\n",
    "    \"key\" :\"c32566670faf404dfa55e752848209f5\",\n",
    "    \"address\" :\"广东省广州市中山大学南方学院\"\n",
    "}\n",
    "# 5. 发起请求\n",
    "r = requests.get(url = geo_url, params = payload) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "f3f2ad7c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'113.679287,23.632575'"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院_location = r.json()['geocodes'][0]['location']\n",
    "广州南方学院_location"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "e9429922",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "regeo_url = \"https://restapi.amap.com/v3/geocode/regeo?parameters\"\n",
    "payload = {\n",
    "    \"key\":\"c32566670faf404dfa55e752848209f5\",\n",
    "    \"location\":广州南方学院_location\n",
    "    \n",
    "}\n",
    "r = requests.get(url = regeo_url, params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "890c3cbd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "7fd1c3f1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'regeocode': {'addressComponent': {'city': '广州市',\n",
       "   'province': '广东省',\n",
       "   'adcode': '440117',\n",
       "   'district': '从化区',\n",
       "   'towncode': '440117100000',\n",
       "   'streetNumber': {'number': '882号',\n",
       "    'location': '113.679226,23.632528',\n",
       "    'direction': '西南',\n",
       "    'distance': '8.10295',\n",
       "    'street': '博学路'},\n",
       "   'country': '中国',\n",
       "   'township': '温泉镇',\n",
       "   'businessAreas': [[]],\n",
       "   'building': {'name': [], 'type': []},\n",
       "   'neighborhood': {'name': [], 'type': []},\n",
       "   'citycode': '020'},\n",
       "  'formatted_address': '广东省广州市从化区温泉镇佳乐堡(南方分店)广州南方学院'},\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000'}"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "25c20ea9",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "regeo_url = \"https://restapi.amap.com/v3/geocode/regeo?parameters\"\n",
    "payload = {\n",
    "    \"key\":\"c32566670faf404dfa55e752848209f5\",\n",
    "    \"location\":广州南方学院_location,\n",
    "    \"extensions\":\"all\",\n",
    "    \"poitype\":\"true\",\n",
    "    \n",
    "}\n",
    "r = requests.get(url = regeo_url, params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "24d83cd8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "f55d19ec",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'regeocode': {'formatted_address': '广东省广州市从化区温泉镇佳乐堡(南方分店)广州南方学院',\n",
       "  'addressComponent': {'country': '中国',\n",
       "   'province': '广东省',\n",
       "   'city': '广州市',\n",
       "   'citycode': '020',\n",
       "   'district': '从化区',\n",
       "   'adcode': '440117',\n",
       "   'township': '温泉镇',\n",
       "   'towncode': '440117100000',\n",
       "   'neighborhood': {'name': [], 'type': []},\n",
       "   'building': {'name': [], 'type': []},\n",
       "   'streetNumber': {'street': '博学路',\n",
       "    'number': '882号',\n",
       "    'location': '113.679226,23.632528',\n",
       "    'direction': '西南',\n",
       "    'distance': '8.10295'},\n",
       "   'businessAreas': [[]]},\n",
       "  'pois': [{'id': 'B00140MR9A',\n",
       "    'name': '广州南方学院',\n",
       "    'type': '科教文化服务;学校;高等院校',\n",
       "    'tel': [],\n",
       "    'direction': '西',\n",
       "    'distance': '3.06387',\n",
       "    'location': '113.679257,23.632577',\n",
       "    'address': '温泉大道882号',\n",
       "    'poiweight': '0.450402',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU99RM',\n",
       "    'name': '广州南方学院图书馆',\n",
       "    'type': '科教文化服务;图书馆;图书馆',\n",
       "    'tel': '020-61787368;020-61787371',\n",
       "    'direction': '西北',\n",
       "    'distance': '23.6163',\n",
       "    'location': '113.679177,23.632762',\n",
       "    'address': '温泉大道882号广州南方学院内',\n",
       "    'poiweight': '0.257947',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD58NF8',\n",
       "    'name': '广州南方学院达人书院',\n",
       "    'type': '科教文化服务;科教文化场所;科教文化场所',\n",
       "    'tel': [],\n",
       "    'direction': '西南',\n",
       "    'distance': '32.2733',\n",
       "    'location': '113.679041,23.632392',\n",
       "    'address': '温泉大道882号广州南方学院新综合楼2层',\n",
       "    'poiweight': '0.191229',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD58FR2',\n",
       "    'name': '广州南方学院教学楼9号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '69.1226',\n",
       "    'location': '113.679747,23.633032',\n",
       "    'address': '广州南方学院',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU92JC',\n",
       "    'name': '广州南方学院4号实验楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '东',\n",
       "    'distance': '69.4077',\n",
       "    'location': '113.679963,23.632652',\n",
       "    'address': '博学路附近',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD599JM',\n",
       "    'name': '广州南方学院第11教学楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '101.294',\n",
       "    'location': '113.680037,23.633173',\n",
       "    'address': '温泉大道882号广州南方学院',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HG5Z9JNK',\n",
       "    'name': '广州南方学院教学楼7号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '西北',\n",
       "    'distance': '109.298',\n",
       "    'location': '113.678600,23.633330',\n",
       "    'address': '博学路',\n",
       "    'poiweight': '0.221553',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU7T1K',\n",
       "    'name': '广州南方学院教学楼10号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '132.988',\n",
       "    'location': '113.680125,23.633492',\n",
       "    'address': '从莞深高速(广州南方学院)',\n",
       "    'poiweight': '0.191229',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD592BJ',\n",
       "    'name': '广州南方学院综合楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '东南',\n",
       "    'distance': '142.466',\n",
       "    'location': '113.680117,23.631544',\n",
       "    'address': '温泉大道886号广州南方学院内',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0H25SMRKP',\n",
       "    'name': '广州南方学院大礼堂',\n",
       "    'type': '科教文化服务;会展中心;会展中心',\n",
       "    'tel': [],\n",
       "    'direction': '东南',\n",
       "    'distance': '143.881',\n",
       "    'location': '113.680076,23.631502',\n",
       "    'address': '温泉大道882号',\n",
       "    'poiweight': '0.263595',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU6Z41',\n",
       "    'name': '广州南方学院教学楼6号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '西北',\n",
       "    'distance': '153.818',\n",
       "    'location': '113.678424,23.633710',\n",
       "    'address': '温泉大道882',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD580NZ',\n",
       "    'name': '广州南方学院惟贤门',\n",
       "    'type': '科教文化服务;学校;高等院校',\n",
       "    'tel': [],\n",
       "    'direction': '西北',\n",
       "    'distance': '154.082',\n",
       "    'location': '113.678437,23.633721',\n",
       "    'address': '博学路7号附近',\n",
       "    'poiweight': '0.285712',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFL7C054',\n",
       "    'name': '广州U优森特酒店',\n",
       "    'type': '住宿服务;住宿服务相关;住宿服务相关',\n",
       "    'tel': '15813395296',\n",
       "    'direction': '西南',\n",
       "    'distance': '8.10295',\n",
       "    'location': '113.679226,23.632528',\n",
       "    'address': '温泉镇博学路882号(广州南方学院商业中心1层)',\n",
       "    'poiweight': '0.317505',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU8NLD',\n",
       "    'name': '广州南方学院1号实验楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '西南',\n",
       "    'distance': '172.86',\n",
       "    'location': '113.678215,23.631370',\n",
       "    'address': '博学路附近',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFHQXIPV',\n",
       "    'name': '惠仁轩cafe(图书馆店)',\n",
       "    'type': '餐饮服务;餐饮相关场所;餐饮相关',\n",
       "    'tel': [],\n",
       "    'direction': '西北',\n",
       "    'distance': '62.8434',\n",
       "    'location': '113.678800,23.632922',\n",
       "    'address': '温泉大道882号广州南方学院行政楼1号',\n",
       "    'poiweight': '0.155825',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFHRQMFN',\n",
       "    'name': '佳乐堡(南方分店)',\n",
       "    'type': '餐饮服务;快餐厅;快餐厅',\n",
       "    'tel': [],\n",
       "    'direction': 'Center',\n",
       "    'distance': '0',\n",
       "    'location': '113.679287,23.632575',\n",
       "    'address': '温泉镇广州南方学院第六食堂3层',\n",
       "    'poiweight': '0.180887',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD57E3S',\n",
       "    'name': '广州南方学院政商研究院',\n",
       "    'type': '科教文化服务;科教文化场所;科教文化场所',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '195.914',\n",
       "    'location': '113.680427,23.633994',\n",
       "    'address': '温泉镇博学路广州南方学院9号教学楼',\n",
       "    'poiweight': '0.191229',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFJYR6P4',\n",
       "    'name': '雅馨蛋糕(中山大学店)',\n",
       "    'type': '餐饮服务;糕饼店;糕饼店',\n",
       "    'tel': [],\n",
       "    'direction': '西北',\n",
       "    'distance': '23.6163',\n",
       "    'location': '113.679177,23.632762',\n",
       "    'address': '温泉镇温泉大道882号广州南方学院内',\n",
       "    'poiweight': '0.209446',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFK28XPU',\n",
       "    'name': '我家厨房',\n",
       "    'type': '餐饮服务;中餐厅;中餐厅',\n",
       "    'tel': [],\n",
       "    'direction': '南',\n",
       "    'distance': '1.3944',\n",
       "    'location': '113.679291,23.632563',\n",
       "    'address': '博学路广州南方学院后门润泰超市首层23号',\n",
       "    'poiweight': '0.213875',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFHHKASW',\n",
       "    'name': '栗子家蛋糕店',\n",
       "    'type': '餐饮服务;糕饼店;糕饼店',\n",
       "    'tel': [],\n",
       "    'direction': '西',\n",
       "    'distance': '0.414997',\n",
       "    'location': '113.679283,23.632574',\n",
       "    'address': '温泉镇广州南方学院后门润泰超市1层',\n",
       "    'poiweight': '0.210069',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFKP81F4',\n",
       "    'name': '政商研究院教学楼9号',\n",
       "    'type': '科教文化服务;学校;高等院校',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '163.951',\n",
       "    'location': '113.679949,23.633919',\n",
       "    'address': '博学路与中山路交叉口东320米',\n",
       "    'poiweight': '0.191742',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFKTDMOI',\n",
       "    'name': '过气轻食屋',\n",
       "    'type': '餐饮服务;餐饮相关场所;餐饮相关',\n",
       "    'tel': [],\n",
       "    'direction': '西南',\n",
       "    'distance': '0.232291',\n",
       "    'location': '113.679286,23.632573',\n",
       "    'address': '温泉镇广州南方学院后门润泰超市一楼05号',\n",
       "    'poiweight': '0.23029',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFKT4WNY',\n",
       "    'name': '莫凡烧烤',\n",
       "    'type': '餐饮服务;餐饮相关场所;餐饮相关',\n",
       "    'tel': [],\n",
       "    'direction': '西南',\n",
       "    'distance': '0.232291',\n",
       "    'location': '113.679286,23.632573',\n",
       "    'address': '温泉镇广州南方学院后门润泰超市一楼05号',\n",
       "    'poiweight': '0.215749',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0G2K6PX0X',\n",
       "    'name': '第1烤场',\n",
       "    'type': '餐饮服务;餐饮相关场所;餐饮相关',\n",
       "    'tel': '13538825321',\n",
       "    'direction': '西南',\n",
       "    'distance': '0.232291',\n",
       "    'location': '113.679286,23.632573',\n",
       "    'address': '温泉镇广州南方学院后门润泰超市1层05号商铺',\n",
       "    'poiweight': '0.216067',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0GKSDK3I1',\n",
       "    'name': '珍味烧鹅',\n",
       "    'type': '餐饮服务;快餐厅;快餐厅',\n",
       "    'tel': [],\n",
       "    'direction': '东',\n",
       "    'distance': '0.442092',\n",
       "    'location': '113.679291,23.632574',\n",
       "    'address': '广州南方学院博学路6号',\n",
       "    'poiweight': '0.214197',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0GKHC2KQN',\n",
       "    'name': '湘味小厨',\n",
       "    'type': '餐饮服务;中餐厅;中餐厅',\n",
       "    'tel': '13005184390',\n",
       "    'direction': '西南',\n",
       "    'distance': '0.521925',\n",
       "    'location': '113.679283,23.632572',\n",
       "    'address': '温泉镇广州南方学院后门润泰超市1层05号商铺',\n",
       "    'poiweight': '0.216746',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0G14PDQVA',\n",
       "    'name': '井禾寿司',\n",
       "    'type': '餐饮服务;外国餐厅;外国餐厅',\n",
       "    'tel': [],\n",
       "    'direction': '西',\n",
       "    'distance': '9.9025',\n",
       "    'location': '113.679193,23.632552',\n",
       "    'address': '温泉镇博学路广州南方学院后门润泰超市1层05号商铺',\n",
       "    'poiweight': '0.21402',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0G3MU0HVY',\n",
       "    'name': '水滚茶靓',\n",
       "    'type': '餐饮服务;冷饮店;冷饮店',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '16.2338',\n",
       "    'location': '113.679405,23.632673',\n",
       "    'address': '温泉镇广州南方学院后门润泰超市1层05号商铺',\n",
       "    'poiweight': '0.214189',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0G3MR1ULG',\n",
       "    'name': '庄海烧腊店',\n",
       "    'type': '餐饮服务;快餐厅;快餐厅',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '16.2338',\n",
       "    'location': '113.679405,23.632673',\n",
       "    'address': '温泉镇广州南方学院后门润泰超市1层05号商铺',\n",
       "    'poiweight': '0.214396',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0H6ZUSDBT',\n",
       "    'name': '80后铁板烧',\n",
       "    'type': '餐饮服务;外国餐厅;外国餐厅',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '16.2338',\n",
       "    'location': '113.679405,23.632673',\n",
       "    'address': '温泉镇广州南方学院后门润泰超市1层05号商铺',\n",
       "    'poiweight': '0.230225',\n",
       "    'businessarea': []}],\n",
       "  'roads': [{'id': '020F49F0050461206',\n",
       "    'name': '博学路',\n",
       "    'direction': '南',\n",
       "    'distance': '156.951',\n",
       "    'location': '113.68,23.634'},\n",
       "   {'id': '020F49F0050462451',\n",
       "    'name': '中山路',\n",
       "    'direction': '东南',\n",
       "    'distance': '343.951',\n",
       "    'location': '113.677,23.6347'},\n",
       "   {'id': '020F49F006047765',\n",
       "    'name': 'S29从莞深高速',\n",
       "    'direction': '南',\n",
       "    'distance': '807.947',\n",
       "    'location': '113.682,23.6394'}],\n",
       "  'roadinters': [{'direction': '东南',\n",
       "    'distance': '343.951',\n",
       "    'location': '113.676794,23.634661',\n",
       "    'first_id': '020F49F0050461206',\n",
       "    'first_name': '博学路',\n",
       "    'second_id': '020F49F0050462451',\n",
       "    'second_name': '中山路'}],\n",
       "  'aois': [{'id': 'B00140MR9A',\n",
       "    'name': '广州南方学院',\n",
       "    'adcode': '440117',\n",
       "    'location': '113.679257,23.632577',\n",
       "    'area': '528560.656426',\n",
       "    'distance': '0',\n",
       "    'type': '141201'}]}}"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "62797a39",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "aeb7ed35",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>20</th>\n",
       "      <th>21</th>\n",
       "      <th>22</th>\n",
       "      <th>23</th>\n",
       "      <th>24</th>\n",
       "      <th>25</th>\n",
       "      <th>26</th>\n",
       "      <th>27</th>\n",
       "      <th>28</th>\n",
       "      <th>29</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>id</th>\n",
       "      <td>B00140MR9A</td>\n",
       "      <td>B0HGDU99RM</td>\n",
       "      <td>B0HGD58NF8</td>\n",
       "      <td>B0HGD58FR2</td>\n",
       "      <td>B0HGDU92JC</td>\n",
       "      <td>B0HGD599JM</td>\n",
       "      <td>B0HG5Z9JNK</td>\n",
       "      <td>B0HGDU7T1K</td>\n",
       "      <td>B0HGD592BJ</td>\n",
       "      <td>B0H25SMRKP</td>\n",
       "      <td>...</td>\n",
       "      <td>B0FFKP81F4</td>\n",
       "      <td>B0FFKTDMOI</td>\n",
       "      <td>B0FFKT4WNY</td>\n",
       "      <td>B0G2K6PX0X</td>\n",
       "      <td>B0GKSDK3I1</td>\n",
       "      <td>B0GKHC2KQN</td>\n",
       "      <td>B0G14PDQVA</td>\n",
       "      <td>B0G3MU0HVY</td>\n",
       "      <td>B0G3MR1ULG</td>\n",
       "      <td>B0H6ZUSDBT</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>name</th>\n",
       "      <td>广州南方学院</td>\n",
       "      <td>广州南方学院图书馆</td>\n",
       "      <td>广州南方学院达人书院</td>\n",
       "      <td>广州南方学院教学楼9号</td>\n",
       "      <td>广州南方学院4号实验楼</td>\n",
       "      <td>广州南方学院第11教学楼</td>\n",
       "      <td>广州南方学院教学楼7号</td>\n",
       "      <td>广州南方学院教学楼10号</td>\n",
       "      <td>广州南方学院综合楼</td>\n",
       "      <td>广州南方学院大礼堂</td>\n",
       "      <td>...</td>\n",
       "      <td>政商研究院教学楼9号</td>\n",
       "      <td>过气轻食屋</td>\n",
       "      <td>莫凡烧烤</td>\n",
       "      <td>第1烤场</td>\n",
       "      <td>珍味烧鹅</td>\n",
       "      <td>湘味小厨</td>\n",
       "      <td>井禾寿司</td>\n",
       "      <td>水滚茶靓</td>\n",
       "      <td>庄海烧腊店</td>\n",
       "      <td>80后铁板烧</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>type</th>\n",
       "      <td>科教文化服务;学校;高等院校</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>科教文化服务;科教文化场所;科教文化场所</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>科教文化服务;会展中心;会展中心</td>\n",
       "      <td>...</td>\n",
       "      <td>科教文化服务;学校;高等院校</td>\n",
       "      <td>餐饮服务;餐饮相关场所;餐饮相关</td>\n",
       "      <td>餐饮服务;餐饮相关场所;餐饮相关</td>\n",
       "      <td>餐饮服务;餐饮相关场所;餐饮相关</td>\n",
       "      <td>餐饮服务;快餐厅;快餐厅</td>\n",
       "      <td>餐饮服务;中餐厅;中餐厅</td>\n",
       "      <td>餐饮服务;外国餐厅;外国餐厅</td>\n",
       "      <td>餐饮服务;冷饮店;冷饮店</td>\n",
       "      <td>餐饮服务;快餐厅;快餐厅</td>\n",
       "      <td>餐饮服务;外国餐厅;外国餐厅</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>tel</th>\n",
       "      <td>[]</td>\n",
       "      <td>020-61787368;020-61787371</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>13538825321</td>\n",
       "      <td>[]</td>\n",
       "      <td>13005184390</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>direction</th>\n",
       "      <td>西</td>\n",
       "      <td>西北</td>\n",
       "      <td>西南</td>\n",
       "      <td>东北</td>\n",
       "      <td>东</td>\n",
       "      <td>东北</td>\n",
       "      <td>西北</td>\n",
       "      <td>东北</td>\n",
       "      <td>东南</td>\n",
       "      <td>东南</td>\n",
       "      <td>...</td>\n",
       "      <td>东北</td>\n",
       "      <td>西南</td>\n",
       "      <td>西南</td>\n",
       "      <td>西南</td>\n",
       "      <td>东</td>\n",
       "      <td>西南</td>\n",
       "      <td>西</td>\n",
       "      <td>东北</td>\n",
       "      <td>东北</td>\n",
       "      <td>东北</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>distance</th>\n",
       "      <td>3.06387</td>\n",
       "      <td>23.6163</td>\n",
       "      <td>32.2733</td>\n",
       "      <td>69.1226</td>\n",
       "      <td>69.4077</td>\n",
       "      <td>101.294</td>\n",
       "      <td>109.298</td>\n",
       "      <td>132.988</td>\n",
       "      <td>142.466</td>\n",
       "      <td>143.881</td>\n",
       "      <td>...</td>\n",
       "      <td>163.951</td>\n",
       "      <td>0.232291</td>\n",
       "      <td>0.232291</td>\n",
       "      <td>0.232291</td>\n",
       "      <td>0.442092</td>\n",
       "      <td>0.521925</td>\n",
       "      <td>9.9025</td>\n",
       "      <td>16.2338</td>\n",
       "      <td>16.2338</td>\n",
       "      <td>16.2338</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>location</th>\n",
       "      <td>113.679257,23.632577</td>\n",
       "      <td>113.679177,23.632762</td>\n",
       "      <td>113.679041,23.632392</td>\n",
       "      <td>113.679747,23.633032</td>\n",
       "      <td>113.679963,23.632652</td>\n",
       "      <td>113.680037,23.633173</td>\n",
       "      <td>113.678600,23.633330</td>\n",
       "      <td>113.680125,23.633492</td>\n",
       "      <td>113.680117,23.631544</td>\n",
       "      <td>113.680076,23.631502</td>\n",
       "      <td>...</td>\n",
       "      <td>113.679949,23.633919</td>\n",
       "      <td>113.679286,23.632573</td>\n",
       "      <td>113.679286,23.632573</td>\n",
       "      <td>113.679286,23.632573</td>\n",
       "      <td>113.679291,23.632574</td>\n",
       "      <td>113.679283,23.632572</td>\n",
       "      <td>113.679193,23.632552</td>\n",
       "      <td>113.679405,23.632673</td>\n",
       "      <td>113.679405,23.632673</td>\n",
       "      <td>113.679405,23.632673</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>address</th>\n",
       "      <td>温泉大道882号</td>\n",
       "      <td>温泉大道882号广州南方学院内</td>\n",
       "      <td>温泉大道882号广州南方学院新综合楼2层</td>\n",
       "      <td>广州南方学院</td>\n",
       "      <td>博学路附近</td>\n",
       "      <td>温泉大道882号广州南方学院</td>\n",
       "      <td>博学路</td>\n",
       "      <td>从莞深高速(广州南方学院)</td>\n",
       "      <td>温泉大道886号广州南方学院内</td>\n",
       "      <td>温泉大道882号</td>\n",
       "      <td>...</td>\n",
       "      <td>博学路与中山路交叉口东320米</td>\n",
       "      <td>温泉镇广州南方学院后门润泰超市一楼05号</td>\n",
       "      <td>温泉镇广州南方学院后门润泰超市一楼05号</td>\n",
       "      <td>温泉镇广州南方学院后门润泰超市1层05号商铺</td>\n",
       "      <td>广州南方学院博学路6号</td>\n",
       "      <td>温泉镇广州南方学院后门润泰超市1层05号商铺</td>\n",
       "      <td>温泉镇博学路广州南方学院后门润泰超市1层05号商铺</td>\n",
       "      <td>温泉镇广州南方学院后门润泰超市1层05号商铺</td>\n",
       "      <td>温泉镇广州南方学院后门润泰超市1层05号商铺</td>\n",
       "      <td>温泉镇广州南方学院后门润泰超市1层05号商铺</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>poiweight</th>\n",
       "      <td>0.450402</td>\n",
       "      <td>0.257947</td>\n",
       "      <td>0.191229</td>\n",
       "      <td>0.221662</td>\n",
       "      <td>0.221662</td>\n",
       "      <td>0.221662</td>\n",
       "      <td>0.221553</td>\n",
       "      <td>0.191229</td>\n",
       "      <td>0.221662</td>\n",
       "      <td>0.263595</td>\n",
       "      <td>...</td>\n",
       "      <td>0.191742</td>\n",
       "      <td>0.23029</td>\n",
       "      <td>0.215749</td>\n",
       "      <td>0.216067</td>\n",
       "      <td>0.214197</td>\n",
       "      <td>0.216746</td>\n",
       "      <td>0.21402</td>\n",
       "      <td>0.214189</td>\n",
       "      <td>0.214396</td>\n",
       "      <td>0.230225</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>businessarea</th>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10 rows × 30 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                0                          1   \\\n",
       "id                      B00140MR9A                 B0HGDU99RM   \n",
       "name                        广州南方学院                  广州南方学院图书馆   \n",
       "type                科教文化服务;学校;高等院校             科教文化服务;图书馆;图书馆   \n",
       "tel                             []  020-61787368;020-61787371   \n",
       "direction                        西                         西北   \n",
       "distance                   3.06387                    23.6163   \n",
       "location      113.679257,23.632577       113.679177,23.632762   \n",
       "address                   温泉大道882号            温泉大道882号广州南方学院内   \n",
       "poiweight                 0.450402                   0.257947   \n",
       "businessarea                    []                         []   \n",
       "\n",
       "                                2                     3   \\\n",
       "id                      B0HGD58NF8            B0HGD58FR2   \n",
       "name                    广州南方学院达人书院           广州南方学院教学楼9号   \n",
       "type          科教文化服务;科教文化场所;科教文化场所          科教文化服务;学校;学校   \n",
       "tel                             []                    []   \n",
       "direction                       西南                    东北   \n",
       "distance                   32.2733               69.1226   \n",
       "location      113.679041,23.632392  113.679747,23.633032   \n",
       "address       温泉大道882号广州南方学院新综合楼2层                广州南方学院   \n",
       "poiweight                 0.191229              0.221662   \n",
       "businessarea                    []                    []   \n",
       "\n",
       "                                4                     5   \\\n",
       "id                      B0HGDU92JC            B0HGD599JM   \n",
       "name                   广州南方学院4号实验楼          广州南方学院第11教学楼   \n",
       "type                  科教文化服务;学校;学校          科教文化服务;学校;学校   \n",
       "tel                             []                    []   \n",
       "direction                        东                    东北   \n",
       "distance                   69.4077               101.294   \n",
       "location      113.679963,23.632652  113.680037,23.633173   \n",
       "address                      博学路附近        温泉大道882号广州南方学院   \n",
       "poiweight                 0.221662              0.221662   \n",
       "businessarea                    []                    []   \n",
       "\n",
       "                                6                     7   \\\n",
       "id                      B0HG5Z9JNK            B0HGDU7T1K   \n",
       "name                   广州南方学院教学楼7号          广州南方学院教学楼10号   \n",
       "type                  科教文化服务;学校;学校          科教文化服务;学校;学校   \n",
       "tel                             []                    []   \n",
       "direction                       西北                    东北   \n",
       "distance                   109.298               132.988   \n",
       "location      113.678600,23.633330  113.680125,23.633492   \n",
       "address                        博学路         从莞深高速(广州南方学院)   \n",
       "poiweight                 0.221553              0.191229   \n",
       "businessarea                    []                    []   \n",
       "\n",
       "                                8                     9   ...  \\\n",
       "id                      B0HGD592BJ            B0H25SMRKP  ...   \n",
       "name                     广州南方学院综合楼             广州南方学院大礼堂  ...   \n",
       "type                  科教文化服务;学校;学校      科教文化服务;会展中心;会展中心  ...   \n",
       "tel                             []                    []  ...   \n",
       "direction                       东南                    东南  ...   \n",
       "distance                   142.466               143.881  ...   \n",
       "location      113.680117,23.631544  113.680076,23.631502  ...   \n",
       "address            温泉大道886号广州南方学院内              温泉大道882号  ...   \n",
       "poiweight                 0.221662              0.263595  ...   \n",
       "businessarea                    []                    []  ...   \n",
       "\n",
       "                                20                    21  \\\n",
       "id                      B0FFKP81F4            B0FFKTDMOI   \n",
       "name                    政商研究院教学楼9号                 过气轻食屋   \n",
       "type                科教文化服务;学校;高等院校      餐饮服务;餐饮相关场所;餐饮相关   \n",
       "tel                             []                    []   \n",
       "direction                       东北                    西南   \n",
       "distance                   163.951              0.232291   \n",
       "location      113.679949,23.633919  113.679286,23.632573   \n",
       "address            博学路与中山路交叉口东320米  温泉镇广州南方学院后门润泰超市一楼05号   \n",
       "poiweight                 0.191742               0.23029   \n",
       "businessarea                    []                    []   \n",
       "\n",
       "                                22                      23  \\\n",
       "id                      B0FFKT4WNY              B0G2K6PX0X   \n",
       "name                          莫凡烧烤                    第1烤场   \n",
       "type              餐饮服务;餐饮相关场所;餐饮相关        餐饮服务;餐饮相关场所;餐饮相关   \n",
       "tel                             []             13538825321   \n",
       "direction                       西南                      西南   \n",
       "distance                  0.232291                0.232291   \n",
       "location      113.679286,23.632573    113.679286,23.632573   \n",
       "address       温泉镇广州南方学院后门润泰超市一楼05号  温泉镇广州南方学院后门润泰超市1层05号商铺   \n",
       "poiweight                 0.215749                0.216067   \n",
       "businessarea                    []                      []   \n",
       "\n",
       "                                24                      25  \\\n",
       "id                      B0GKSDK3I1              B0GKHC2KQN   \n",
       "name                          珍味烧鹅                    湘味小厨   \n",
       "type                  餐饮服务;快餐厅;快餐厅            餐饮服务;中餐厅;中餐厅   \n",
       "tel                             []             13005184390   \n",
       "direction                        东                      西南   \n",
       "distance                  0.442092                0.521925   \n",
       "location      113.679291,23.632574    113.679283,23.632572   \n",
       "address                广州南方学院博学路6号  温泉镇广州南方学院后门润泰超市1层05号商铺   \n",
       "poiweight                 0.214197                0.216746   \n",
       "businessarea                    []                      []   \n",
       "\n",
       "                                     26                      27  \\\n",
       "id                           B0G14PDQVA              B0G3MU0HVY   \n",
       "name                               井禾寿司                    水滚茶靓   \n",
       "type                     餐饮服务;外国餐厅;外国餐厅            餐饮服务;冷饮店;冷饮店   \n",
       "tel                                  []                      []   \n",
       "direction                             西                      东北   \n",
       "distance                         9.9025                 16.2338   \n",
       "location           113.679193,23.632552    113.679405,23.632673   \n",
       "address       温泉镇博学路广州南方学院后门润泰超市1层05号商铺  温泉镇广州南方学院后门润泰超市1层05号商铺   \n",
       "poiweight                       0.21402                0.214189   \n",
       "businessarea                         []                      []   \n",
       "\n",
       "                                  28                      29  \n",
       "id                        B0G3MR1ULG              B0H6ZUSDBT  \n",
       "name                           庄海烧腊店                  80后铁板烧  \n",
       "type                    餐饮服务;快餐厅;快餐厅          餐饮服务;外国餐厅;外国餐厅  \n",
       "tel                               []                      []  \n",
       "direction                         东北                      东北  \n",
       "distance                     16.2338                 16.2338  \n",
       "location        113.679405,23.632673    113.679405,23.632673  \n",
       "address       温泉镇广州南方学院后门润泰超市1层05号商铺  温泉镇广州南方学院后门润泰超市1层05号商铺  \n",
       "poiweight                   0.214396                0.230225  \n",
       "businessarea                      []                      []  \n",
       "\n",
       "[10 rows x 30 columns]"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.json_normalize(r.json()['regeocode']['pois']).T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bf993f3e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
